import { GetterTree, Getter } from 'vuex'
import { State } from './state'

/**
 * 主版本号
 * @param state
 * @returns
 */
export const majorVersion: Getter<State, any> = (state: State) => {
  const version = state.version
  if (!version) {
    return null
  }
  return version.split('.')[0]
}

export const userInfo: Getter<State, any> = (state: State) => {
  const frameState = state.frameState || {}
  return frameState.userInfo || {}
}

export default {
  majorVersion,
  userInfo,
} as GetterTree<State, any>
